﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Threading;
using SedCup.Code.Model;
using SedCup.Code.View.Forms;

namespace SedCup
{
    public class MainController
    {
        private MainDAO mainDAO;
        public MainWindow mainWindow;

        #region StartApp

        /// <summary>
        /// Constructor
        /// </summary>
        public MainController()
        {
            if (!Settings.DEMO)
            {
                //new SedCup.Code.Control.ConnectExample();

                string url = System.Environment.GetEnvironmentVariable("URL");
                //string TeamName = "Client1";
                string TeamName = "ad4123ddea477e3ca61b233973be109e";
                SEDCupConsole.Example.ConnectToServer("{\"turn\":0,\"hire\":[0,0,0],\"move\":[],\"dojob\":[],\"fire\":[]}", String.Concat(url, TeamName));

                //this.mainDAO = new MainDAO(this);
            }

            this.mainWindow = new MainWindow(this);
        }

        /// <summary>
        /// Start the GUI
        /// </summary>
        public void StartApp()
        {
            Application.Run(this.mainWindow);
        }

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            new MainController().StartApp();
        }

        #endregion StartApp
    }
}
